package com.zhiqiang.gameserver.nettydemo.demo;

import com.zhiqiang.gameserver.netty.NettyGameServerDecoder;
import com.zhiqiang.gameserver.netty.NettyGameServerEncoder;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.protobuf.ProtobufDecoder;
import io.netty.handler.codec.protobuf.ProtobufEncoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;


/**
 * @author YAO
 */
public class LoginServerInit extends ChannelInitializer<SocketChannel>{
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast(new NettyGameServerDecoder());
        ch.pipeline().addLast(new NettyGameServerEncoder());
        ch.pipeline().addLast(new LoginServerHandler());
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
       cause.printStackTrace();
       ctx.close();
    }
}
